package com.zq.sysuser;

import cn.dev33.satoken.secure.SaSecureUtil;
import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.zq.sysuser.dao.entity.RolePermission;
import com.zq.sysuser.dao.entity.User;
import com.zq.sysuser.service.IRolePermissionService;
import com.zq.sysuser.service.IUserService;
import jakarta.annotation.Resource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author 张乔
 * @Date 2024/4/26 17:04
 */
@SpringBootTest
public class test {

@Autowired
    private IUserService sysUserService;

@Test
    void add(){
    User user = new User();
user.setUsername("闫朋");
user.setPassword(SaSecureUtil.md5("123456"));
sysUserService.save(user);

}











@Resource
private IRolePermissionService rolePermissionService;


@Test
    void get() {


    for (int i = 8; i <=11 ; i++) {
        RolePermission rolePermission = new RolePermission();
        rolePermission.setRoleId(1);

        rolePermission.setPermissionId(i);
        rolePermissionService.save(rolePermission);
    }



}

@Test
    void lll(){
    List<User> ll=new ArrayList<>();
    User user = new User();
    ll.add(user);
    System.out.println(ll.size());
    String toJSONString = JSON.toJSONString(ll);
    System.out.println(toJSONString);


}


@Test
    void lllmm(){
//User user = new User();
//user.setUsername("龙三爷");
//user.setId(6);
//
//sysUserService.updateById(user);
//    String now = DateUtil.now("yyyy-MM-dd");
//    System.out.println(now);
    String format = DateUtil.format(new Date(), "yyyy-MM-dd: HH:mm:ss");
    System.out.println(format);
}



@Test
void lllmm1() {
    SqlSessionFactory sqlSessionFactory = null;


    // 输入数据
    double[] numbers = {1.2, 3, 11.4, 15, 30, 128};
    // 分类结果
    List<Object> ones = new ArrayList<>();
    List<Object> tens = new ArrayList<>();
    List<Object> hundreds = new ArrayList<>();
    // 遍历数组，根据数字的大小进行分类
    for (double number : numbers) {
        if (number < 10) {
            ones.add(number);
        } else if (number < 100) {
            tens.add(number);
        } else {
            hundreds.add(number);
        }
    }
    // 输出分类结果
    System.out.println("1: " + ones);
    System.out.println("10: " + tens);
    System.out.println("100: " + hundreds);

}




@Test
    void lllmm2() {

    SaSession session = StpUtil.getSession();
//    String token = tokenSession.getId();
    System.out.println(session);

}


}
